const mongoose = require('mongoose');

const energySchema = new mongoose.Schema({
  building: {
    type: String,
    required: true,
    enum: ['A', 'B', 'C', 'D']
  },
  floor: {
    type: Number,
    required: true
  },
  meterType: {
    type: String,
    enum: ['electricity', 'water', 'gas'],
    required: true
  },
  reading: {
    type: Number,
    required: true
  },
  unit: {
    type: String,
    required: true
  },
  cost: {
    type: Number,
    default: 0
  },
  timestamp: {
    type: Date,
    default: Date.now
  }
}, {
  timestamps: true
});

module.exports = mongoose.model('Energy', energySchema);
